﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SafeLoad.NControl
{
  /// <summary>
  /// NPump.xaml 的交互逻辑
  /// </summary>
  public partial class NPump : UserControl
  {
    public NPump()
    {
      InitializeComponent();
    }

    public static readonly DependencyProperty StateColorProperty =
      DependencyProperty.Register("StateColor", typeof(Color), typeof(NPump), new PropertyMetadata(Colors.White));
    public Color StateColor
    {
      get { return (Color)GetValue(StateColorProperty); }
      set { SetValue(StateColorProperty, value); }
    }

    public static readonly DependencyProperty ActiveProperty =
      DependencyProperty.Register("Active", typeof(bool), typeof(NPump), new PropertyMetadata(false, RerenderBinding));
    public bool Active
    {
      get { return (bool)GetValue(ActiveProperty); }
      set { SetValue(ActiveProperty, value); }
    }


    private static void RerenderBinding(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
      NPump gauge = d as NPump;
      gauge.StateColor = gauge.Active ? Color.FromRgb(0x1A,0xFA,0x29) : Colors.White;
    }
  }
}
